package com.wenjie.controller;

import com.wenjie.original.entity.common.vo.RestBaseVo;
import com.wenjie.original.entity.vo.OrderBox.OrderBoxUpOrAddVo;
import com.wenjie.original.entity.vo.OrderBox.OrderBoxVo;
import com.wenjie.original.service.IOrderBoxService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api("打包计划")
@RestController
@RequestMapping("/api/orderBox")
public class OrderBoxController {

    @Autowired
    private IOrderBoxService orderBoxService;

    @ApiOperation("查询接口")
    @PostMapping("/list")
    public RestBaseVo<OrderBoxVo.ResVo> list(@RequestBody @Validated OrderBoxVo.SelVo selVo) {
        return orderBoxService.list(selVo, OrderBoxVo.ResVo.class);
    }


    @ApiOperation("添加接口")
    @PostMapping("/add")
    public void add(@RequestBody @Validated OrderBoxUpOrAddVo.AddVo addVo) {
        orderBoxService.save(addVo);
    }

    @ApiOperation("修改接口")
    @PostMapping("/up")
    public void up(@RequestBody @Validated OrderBoxUpOrAddVo.UpVo upVo) {
        orderBoxService.updateById(upVo);
    }

    @ApiOperation("删除接口")
    @PostMapping("/del")
    public void del(@RequestBody @Validated Long id) {
        orderBoxService.removeById(id);
    }

}
